package infore.com.cn.servlet;

import infore.com.cn.util.DateJsonValueProcessor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

public class Control extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
//	 private static final String appKey ="b29b6a69b5fa22f01f35bf08";
//	 private static final String masterSecret = "63b8fb4ddde6f8649560bdf1";
	private static final String appKey = "b7d56ee6306a00f7e3cd6a20";
	private static final String masterSecret = "4e53dc8426079a7bec0e7aed";

	@Override
	public void init() throws ServletException {
	}

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setHeader("Content-Type", "application/json;charset=UTF-8");
		response.setCharacterEncoding("utf-8");
		String uri = request.getRequestURI();
		System.out.println(uri);
		uri = uri.substring(uri.lastIndexOf("/"), uri.lastIndexOf("."));
		PrintWriter out = response.getWriter();
		if (uri.equals("/Test")) {
			out.println(jdpush.testSendPush(appKey, masterSecret));
		}
	}
}
